<?php

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
/**
 * Description of RefuseController
 *
 * @author hoangle
 */
class Backend_RefuseController extends Zend_Controller_Action {

//put your code here
    public function init() {
        $this->_helper->layout->setLayout('backend');
        Service_Account::checkLogin(2);
    }
    
    public function index() {
        $this->_forward('get');
    }
    
    public function listAction() {
        //Get question
        $arrQuestion = (array) Service_Model::factory('Question', 'getQuestion', NULL, 'frontend');
        foreach ($arrQuestion as $val) {
            $arrRestQuest[$val['mackid']] = $val['mackname'];
        }

        $result = Service_Model::factory('UserQuestion', 'getAnswerRefuse', NULL, 'backend');

        $arrTemp = array();
        if (!empty($result)) {
            foreach ($result as $val) {
                $arrTemp[$val['mackid']][] = $val;
            }
        }

        $this->view->refuseanswer = $arrTemp;
        $this->view->question = $arrRestQuest;
    }

    /**
     * @desc Allow | No allow refund
     */
    public function ajaxrefundAction() {
        if ($this->_request->isPost()) {
            $arrData = $this->_request->getPost();
            if (!empty($arrData)) {
                $result = Service_Model::factory('UserQuestion', 'allowRefundAnswer', $arrData, 'backend');
                if($result) {
                    echo 'true';
                }
                else {
                    echo 'false';
                }
            }
            else {
                echo 'false';
            }
        }
        exit;
    }

}

?>
